<?php

namespace App\Http\Controllers\Admin;

use App\Models\BuyNews;
use Illuminate\Http\Request;

class BuyNewsController extends BaseController
{
    public function index()
    {
        $items = BuyNews::with('user')->orderByDesc('id')->paginate(20);

        return $this->view('admin.productnews.buys', [
            'items' => $items,
            'pagination' => $items->render()
        ]);
    }

    public function deleteAll(Request $request)
    {
        $items = $request->input('items', []);
        BuyNews::whereIn('id', $items)->delete();
        return $this->messager()->render();
    }
}
